USE tempdb;
GO
SELECT CheckFor
     , SUM (Amount) As Total
FROM CheckRegistry
GROUP BY  ROLLUP (CheckFor); 



USE tempdb;
GO
SELECT COALESCE (CheckFor,'GRAND TOTAL') As CheckFor
     , SUM (Amount) AS Total
FROM CheckRegistry
GROUP BY ROLLUP (CheckFor);



USE tempdb;
GO
SELECT MONTH(CheckDate) AS CheckMonth 
     , coalesce( CheckFor, 'Month Total')
     , SUM (Amount) AS Total
FROM CheckRegistry
GROUP BY ROLLUP (MONTH(CheckDate),CheckFor);






USE tempdb;
GO
SELECT MONTH(CheckDate) AS CheckMonth 
     , CheckFor
     , PayTo
     , SUM (Amount) AS Total
FROM CheckRegistry
GROUP BY ROLLUP (MONTH(CheckDate),CheckFor,PayTo);



USE tempdb;
GO
SELECT CheckFor
     , SUM (Amount) As Total
FROM CheckRegistry
GROUP BY CUBE(CheckFor);   

USE tempdb;
GO

SELECT MONTH(CheckDate) AS CheckMonth 
     , CheckFor
     , SUM (Amount) AS Total
FROM CheckRegistry
GROUP BY CUBE (MONTH(CheckDate),CheckFor)
ORDER by MONTH(CheckDate), CheckFor, Total;


USE tempdb;
GO
SELECT MONTH(CheckDate) AS CheckMonth 
     , CheckFor
     , SUM (Amount) AS Total
FROM CheckRegistry
GROUP BY GROUPING SETS (MONTH(CheckDate),CheckFor);




USE tempdb;
GO
SELECT NULL AS CheckMonth
     , CheckFor
     , SUM (Amount) AS Total
FROM CheckRegistry
GROUP BY CheckFor 
UNION ALL
SELECT MONTH(CheckDate) AS CheckMonth
     , NULL as CheckFor  
     , SUM (Amount) AS Total
FROM CheckRegistry
GROUP BY MONTH(CheckDate);


SELECT MONTH(CheckDate) AS CheckMonth 
     , CheckFor
     , PayTo
     , SUM (Amount) AS Total
FROM CheckRegistry
GROUP BY GROUPING SETS ((MONTH(CheckDate),CheckFor), PayTo);


SELECT MONTH(CheckDate) AS CheckMonth 
     , CheckFor
     , SUM (Amount) AS Total
FROM CheckRegistry
GROUP BY GROUPING SETS (MONTH(CheckDate),CheckFor,());





